package com.kzj.controller;


import com.kzj.domain.ElectiveCourse;
import com.kzj.domain.Teacher;
import com.kzj.domain.dto.InputScoreDTO;
import com.kzj.domain.vo.FreeClassroomDTO;
import com.kzj.global.constant.GlobalConstant;
import com.kzj.global.exception.MyException;
import com.kzj.global.re.Result;
import com.kzj.global.threadLocal.UserThreadLocal;
import com.kzj.global.utils.GlobalUtil;
import com.kzj.service.CourseInformationService;
import com.kzj.service.EletiveCourseService;
import com.kzj.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author kzj
 * @since 2023-12-01
 */
@RestController
@RequestMapping("/teacher")
@Api(tags = "老师相关接口")
public class TeacherController {
    @Autowired
    TeacherService teacherService;
    @ModelAttribute
    public void modelAttribute() {
        String type = UserThreadLocal.getType();
        if(!type.equals(GlobalConstant.TEACHER_TYPE))
            throw new MyException(GlobalConstant.USER_PERMISSION_DENIED);
    }
    @ApiOperation("得到可以选择的课程")
    @GetMapping("/CourseList")
    public Result getCourseList()
    {
        return teacherService.getCourseList();
    }
    @ApiOperation("得到安排的课程列表")
    @GetMapping("/arrangeCourseList")
    public Result getArrangeCourseList()
    {
        return teacherService.getArrangeCourseList();
    }
    @ApiOperation("班主任查询学生")
    @GetMapping("managerialStudent")
    public Result getManagerialStudent()
    {
        return teacherService.getManagerialStudent();
    }
    @ApiOperation("获取空闲的教室")
    @PostMapping("/freeClassroom")
    public Result getFreeClassroom(@RequestBody FreeClassroomDTO freeClassroomDTO)
    {
        return teacherService.getFreeClassroom(freeClassroomDTO);
    }
    @ApiOperation("获取监考信息")
    @GetMapping("/invigilatorInformation/{teacherId}")
    public Result getInvigilatorInformation(@PathVariable String teacherId)
    {
        return teacherService.getInvigilatorInformation(teacherId);
    }
    @ApiOperation("设定成绩")
    @PostMapping("/inputScore")
    public Result inputScore(@RequestBody InputScoreDTO inputScoreDTO)
    {
        //TODO  待测
        return teacherService.inputScore(inputScoreDTO);
    }
    @ApiOperation("得到可录入成绩的学生信息")
    @GetMapping("/getStudentInformationThatCanBeEnteredIntoGrades")
    public Result getStudentInformationThatCanBeEnteredIntoGrades()
    {
        return teacherService.getStudentInformationThatCanBeEnteredIntoGrades();
    }
    @ApiOperation("添加课程")
    @PutMapping("/addElectiveCourse")
    public Result addElectiveCourse(@RequestBody ElectiveCourse electiveCourse)
    {
        return teacherService.addElectiveCourse(electiveCourse);
    }
    @ApiOperation("通过term 获得老师的课表")
    @GetMapping("/getSchedule/{term}")
    public Result getSchedule(@PathVariable String term)
    {
        return teacherService.getSchedule(term);
    }
    @ApiOperation("获得老师本学期的课表")
    @GetMapping("/getCurrentTermSchedule")
    public Result getCurrentTermSchedule()
    {
        return teacherService.getCurrentTermSchedule();
    }
    @ApiOperation("获得老师下学期的课表")
    @GetMapping("/getNextTermSchedule")
    public Result getNextTermSchedule()
    {
        return teacherService.getNextTermSchedule();
    }
    @ApiOperation("获得老师可删的课程列表")
    @GetMapping("/getCanDeleteElectiveCourseList")
    public Result getCanDeleteElectiveCourseList()
    {
        return teacherService.getCanDeleteElectiveCourseList();
    }
    @ApiOperation("修改老师的信息")
    @PutMapping("/updateTeacher")
    public Result updateTeacher(@RequestBody Teacher teacher)
    {
        return teacherService.updateTeacher(teacher);
    }


}

